Ignore ENOTSUP in file locking on Linux too
authorAlex Crichton <alex@alexcrichton.com>
Thu, 1 Jun 2017 19:24:51 +0000 (12:24 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 1 Jun 2017 20:58:27 +0000 (13:58 -0700)
Apparently there are some filesystems that return this!

Closes #4096

src/cargo/util/flock.rs

index 1be77b2d843fd19e8cf5b375ba8622eb2444b92c..505a88a008a885f54381f13b8df62bc49c87edb3 100644 (file)
@@ -271,10 +271,11 @@ fn acquire(config: &Config,
     match try() {
         Ok(()) => return Ok(()),
 
-        // Like above, where we ignore file locking on NFS mounts on Linux, we
-        // do the same on OSX here. Note that ENOTSUP is an OSX_specific
-        // constant.
-        #[cfg(target_os = "macos")]
+        // In addition to ignoring NFS which is commonly not working we also
+        // just ignore locking on filesystems that look like they don't
+        // implement file locking. We detect that here via the return value of
+        // locking (e.g. inspecting errno).
+        #[cfg(unix)]
         Err(ref e) if e.raw_os_error() == Some(libc::ENOTSUP) => return Ok(()),
 
         #[cfg(target_os = "linux")]